/*
 * Copyright (C) 2004, Velocityme Partnership
 * ChangeDeltaTypeBean.java
 *
 * Created on 14 July 2004, 10:52
 */

package com.velocityme.entity;

import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import com.velocityme.interfaces.*;
import com.velocityme.interfaces.ServiceUnavailableException;

/**
 *
 * @author  Robert
 * @ejb.bean
 *           type="CMP"
 *           cmp-version="2.x"
 *           name="ChangeDeltaType"
 *           jndi-name="ejb/ChangeDeltaType"
 *           view-type="local"
 * @ejb.transaction type="Required"
 *
 * @ejb.value-object match="*"
 *
 * @ejb.persistence table-name="changedeltatype"
 *
 * @ejb.util generate="physical"
 *
 * @jboss.persistence create-table="true"
 *                    remove-table="false"
 */
public abstract class ChangeDeltaTypeBean implements EntityBean {
    
    public static final int CREATE = 0;
    public static final int EDIT = 1;
    public static final int MODERATE = 2;
    public static final int CHANGE_STATE = 3;
    public static final int EDIT_TIME = 4;
    public static final int DELETE_TIME = 5;
    public static final int SET_PASSWORD = 6;
    public static final int MOVE = 7;
    public static final int MOVE_CHILD = 8;
    public static final int POST_COMMENT = 9;
    public static final int CREATE_USER_ACCESS = 10;
    public static final int DELETE_USER_ACCESS = 11;
    public static final int INTERESTED = 12;
    public static final int DELETE_NODE = 13;
    public static final int CREATE_GROUP_ACCESS = 14;
    public static final int DELETE_GROUP_ACCESS = 15;
    public static final int REASSIGN_RESPONSIBILITY = 16;
    public static final int CREATE_LINK = 17;
    public static final int DELETE_LINK = 18;
    public static final int CREATE_DEPENDENCY = 19;
    public static final int DELETE_DEPENDENCY = 20;
    public static final int NUM_TYPES = 21;

    /**
    * Context set by container
    */
    private javax.ejb.EntityContext m_entityContext;

    public void setEntityContext(javax.ejb.EntityContext entityContext) {
        m_entityContext = entityContext;
    }

    public void unsetEntityContext() {
        m_entityContext = null;
    }
  
    /** @ejb.create-method */
    public ChangeDeltaTypePK ejbCreate(java.lang.Integer p_type) throws javax.ejb.CreateException {
        setChangeDeltaTypeId(p_type);
        // EJB 2.0 spec says return null for CMP ejbCreate methods.
        return null;
    }

    public void ejbPostCreate(java.lang.Integer p_type) throws javax.ejb.CreateException {
        // CMR relations must be set in ejbPostCreate
        String name;
        switch(p_type.intValue()) {
            case CREATE:                    name = "Create"; break;
            case EDIT:                      name = "Edit"; break;
            case MODERATE:                  name = "Moderate"; break;
            case CHANGE_STATE:              name = "Change State"; break;
            case EDIT_TIME:                 name = "Edit Time"; break;
            case DELETE_TIME:               name = "Delete Time"; break;
            case SET_PASSWORD:              name = "Set Password"; break;
            case MOVE:                      name = "Move"; break;
            case MOVE_CHILD:                name = "Move Child"; break;
            case POST_COMMENT:              name = "Post Comment"; break;
            case CREATE_USER_ACCESS:        name = "Create User Access"; break;
            case DELETE_USER_ACCESS:        name = "Delete User Access"; break;
            case INTERESTED:                name = "Interested"; break;
            case DELETE_NODE:               name = "Delete Node"; break;
            case CREATE_GROUP_ACCESS:       name = "Create Group Access"; break;
            case DELETE_GROUP_ACCESS:       name = "Delete Group Access"; break;
            case REASSIGN_RESPONSIBILITY:   name = "Reassign Responsibility"; break;
            case CREATE_LINK:               name = "Create Link"; break;
            case DELETE_LINK:               name = "Delete Link"; break;
            case CREATE_DEPENDENCY:         name = "Create Dependency"; break;
            case DELETE_DEPENDENCY:         name = "Delete Dependency"; break;
            default:                        name = "Unknown ChangeDeltaType"; break;
        }
        setName(name);
    }
    
    /**
     *  This gets a local object from a remote object.
     *  @ejb.interface-method view-type="remote"
     */
    public ChangeDeltaTypeLocal getLocal() {
        return (ChangeDeltaTypeLocal)m_entityContext.getEJBLocalObject();
    }
    
    /** @ejb.interface-method view-type="local" */
    public abstract com.velocityme.valueobjects.ChangeDeltaTypeValue getChangeDeltaTypeValue();

    //=======================================================================
    //
    //                   ATTRIBUTES
    //
    //=======================================================================
      
    /**
     * @ejb.persistence column-name="changeDeltaTypeId"
     * @ejb.interface-method view-type="local"
     * @ejb.pk-field 
     */
    public abstract java.lang.Integer getChangeDeltaTypeId();
    public abstract void setChangeDeltaTypeId(java.lang.Integer changeDeltaTypeId);
    
    /**
     * @ejb.persistence column-name="name"
     * @ejb.interface-method view-type="local"
     */
    public abstract java.lang.String getName();
    public abstract void setName(java.lang.String name);
    
    //=======================================================================
    //
    //                   RELATIONSHIPS
    //
    //=======================================================================
    
    //=======================================================================
    //
    //                   MANAGEMENT METHODS
    //
    //=======================================================================
    
}
